var xmlDoc = null;
var xIsoMenu = null;
var eMenu=null;

window.onload=function(e){
	//initialize
	xmlDoc = Sarissa.getDomDocument();
	xmlDoc.async = false;
	xmlDoc.load("isoTopix.xml");
	xIsoMenu = Sarissa.getDomDocument();
    // the following two lines are needed for IE in order to use proper xpath
    xIsoMenu.setProperty("SelectionNamespaces", "xmlns:xsl='http://www.w3.org/1999/XSL/Transform'");
    xIsoMenu.setProperty("SelectionLanguage", "XPath");
    //load async
	xIsoMenu.async = false;
	xIsoMenu.load("menu.xml");
	initISOMenu(xIsoMenu.selectSingleNode("//menubar"));
	//window.alert(new XMLSerializer().serializeToString(xIsoMenu));
	//render menu
	goMenu(0);
}

function initISOMenu(xMenuBar){
	//fill my menu from mainXml
	var menuModel = new DHTMLSuite.menuModel();
	var myNode=null;
	var xMenuDir=null;
	var curM=null;
	var i=-1;

	//init DHTMLSuite
	DHTMLSuite.commonObj.setCssCacheStatus(false);

    //init menu-element
	eMenu=xmlDoc.getElementsByTagName("d");
	while(++i!=eMenu.length){
		//determine parent-id - if any set menuwidth; TODO: set to largest*8
		if((curM=eMenu[i].attributes.getNamedItem("pid")?eMenu[i].attributes.getNamedItem("pid").nodeValue:null))
			menuModel.setSubMenuWidth(curM,155);
		menuModel.addItem(eMenu[i].attributes.getNamedItem("mid").nodeValue,
			eMenu[i].attributes.getNamedItem("head").nodeValue, '', '',
			curM, "", eMenu[i].firstChild?"window.goMenu('" + i + "')":"");
		//all parents are separated - thats the new Trend
		if(!curM)menuModel.addSeparator();
	}
	
	menuModel.init();
	
	//fill the bar
	var menuBar = new DHTMLSuite.menuBar();
	menuBar.addMenuItems(menuModel);
	menuBar.setTarget('isoMenu');
	menuBar.init();
}

function mailToUs(e){
	return "<a href=" + "mai" + "lto:" + e + "&#" + 64
	+ ";evolve-it." + "dk>" + e + "&#" + 64 + ";evolve-it." + "dk" + "</a> ";
}

function goMenu(i){
    var e=eMenu[i], s="";
    //recurse parents
    do s=" > " + e.attributes.getNamedItem("head").nodeValue + s;
    while(e.attributes.getNamedItem("pid") && (e=xmlDoc.selectSingleNode("*/*/d[@mid='"
    		+ e.attributes.getNamedItem("pid").nodeValue + "']")));
	//display navigation status and text
	document.getElementById('isoBody').innerHTML='<b>' + s.substr(3) + '</b>' + eMenu[i].firstChild.nodeValue;
	if(e=document.getElementById('mailUs'))
		e.innerHTML=mailToUs("info");
}
